package com.yanfan.xmzS7;

import com.alibaba.fastjson2.JSONObject;
import com.github.s7connector.api.annotation.S7Variable;
import com.github.s7connector.impl.utils.S7Type;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @Auther: Zg
 * @Date: 2022/11/23 - 11 - 23 - 17:13
 * @Description: com.zg.mymes.myConnPLC.myS7.myS7entities
 * @version: 1.0
 * 可定制化的PLC值
 */
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class StPlcS7Entity {

    //必须为public 否则报错
    /**
     * 是否急停
     */
    @S7Variable(byteOffset = 0, bitOffset = 0, type = S7Type.BOOL)
    public Boolean stop;

    /**
     * 自动模式
     */
    @S7Variable(byteOffset = 0, bitOffset = 1, type = S7Type.BOOL)
    public Boolean autoMode;

    /**
     * 心跳包
     */
    @S7Variable(byteOffset = 2, type = S7Type.WORD)
    public Integer heartBeat;

    /**
     * 测试中
     */
    @S7Variable(byteOffset = 4, bitOffset = 0, type = S7Type.BOOL)
    public Boolean test;

    /**
     * 开阀门
     */
    @S7Variable(byteOffset = 4, bitOffset = 1, type = S7Type.BOOL)
    public Boolean open;

    /**
     * 关阀门
     */
    @S7Variable(byteOffset = 4, bitOffset = 2, type = S7Type.BOOL)
    public Boolean close;

    /**
     * 保压中
     */
    @S7Variable(byteOffset = 4, bitOffset = 3, type = S7Type.BOOL)
    public Boolean pressure;

    /**
     * 测试完成
     */
    @S7Variable(byteOffset = 4, bitOffset = 4, type = S7Type.BOOL)
    public Boolean testComplete;

    /**
     * 差压泄露
     */
    @S7Variable(byteOffset = 6, type = S7Type.REAL)
    public Double diffPressureLeakage;

    /**
     * 水气泡泄露
     */
    @S7Variable(byteOffset = 10, type = S7Type.REAL)
    public Double waterBubblesLeaking;

    /**
     * 判定结果
     */
    @S7Variable(byteOffset = 14, type = S7Type.WORD)
    public Integer judgmentResults;

    /**
     * 上压力
     */
    @S7Variable(byteOffset = 16, type = S7Type.REAL)
    public Double upperPressure;

    /**
     * 中压力
     */
    @S7Variable(byteOffset = 20, type = S7Type.REAL)
    public Double centerPressure;

    /**
     * 下压力
     */
    @S7Variable(byteOffset = 24, type = S7Type.REAL)
    public Double downPressure;

    /**
     * 位（预留）
     */
    @S7Variable(byteOffset = 28, type = S7Type.STRUCT)
    public JSONObject bitObj;

    /**
     * INT（预留）
     */
    @S7Variable(byteOffset = 30, type = S7Type.STRUCT)
    public JSONObject intObj;

    /**
     * REAL（预留）
     */
    @S7Variable(byteOffset = 54, type = S7Type.STRUCT)
    public JSONObject realObj;

//    =======================================================写入=============================================================
    /**
     * 在线
     */
    @S7Variable(byteOffset = 98, bitOffset = 0, type = S7Type.BOOL)
    public Boolean wonline;
    /**
     * 开始
     */
    @S7Variable(byteOffset = 98, bitOffset = 1, type = S7Type.BOOL)
    public Boolean wstart;
    /**
     * 停止
     */
    @S7Variable(byteOffset = 98, bitOffset = 2, type = S7Type.BOOL)
    public Boolean wstop;

    /**
     * 测试项
     */
    @S7Variable(byteOffset = 100, type = S7Type.WORD)
    public Integer wtest;
    /**
     * 测试压力
     */
    @S7Variable(byteOffset = 102, type = S7Type.REAL)
    public Double wtestPressure;

    /**
     * 测试时间
     */
    @S7Variable(byteOffset = 106, type = S7Type.TIME)
    public Long wtestTime;

    /**
     * 位（预留）
     */
    @S7Variable(byteOffset = 110, type = S7Type.STRUCT)
    public JSONObject wbitObj;

    /**
     * INT（预留）
     */
    /*@S7Variable(byteOffset = 112, type = S7Type.STRUCT)
    public JSONObject wintObj;*/

    /**
     * INT（预留） 测试介质
     */
    @S7Variable(byteOffset = 112, type = S7Type.WORD)
    public Integer wtestMedium;

    /**
     * INT（预留） 心跳数据监测
     */
    @S7Variable(byteOffset = 114, type = S7Type.WORD)
    public Integer wheartBeat;

    /**
     * REAL（预留）
     */
    @S7Variable(byteOffset = 136, type = S7Type.STRUCT)
    public JSONObject wrealObj;

    /*
    @S7Variable(byteOffset = 2, type = S7Type.WORD)
    public Integer heartBeat;
    @S7Variable(byteOffset = 98, bitOffset = 2, type = S7Type.BOOL)
    public Boolean wstop;
    @S7Variable(byteOffset = 106, type = S7Type.TIME)
    public Long wtestTime;
    @S7Variable(byteOffset = 168, type = S7Type.REAL)
    public Double testAlarm;
    @S7Variable(byteOffset = 606, size = 130, type = S7Type.STRING)
    public String var100;
    @S7Variable(byteOffset = 54, type = S7Type.STRUCT)
    public JSONObject realObj;
    */


}

